<template>
  <div class="play-source">
    <div class="online-play">
      <div class="play-url">
        <span class="u-item" v-for="(uitem,uindex) in urlList" :key="uindex" @click="changeUrl(uitem)"><i class="icon el-icon-upload"></i>{{uitem.txt}}</span>
      </div>
      <div class="page-box">
        <i class="icon-page icon-top"></i>
        <div class="pages" v-if="pageList.length">
          <span class="page-item" v-for="(pitem,pindex) in pageList" :key="pindex" @click="playMovie(pitem)">{{pitem.txt}}</span>
        </div>
        <div v-else>暂无资源</div>
        <div v-show="pageList.length >= 2" class="sort">
          <span class="s-pos" @click="reverse">倒序</span>
          <span class="s-neg" @click="reverse">顺序</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PlaySource',
  props: {
    urlList: {
      type: Array
    },
    pageList: {
      type: Array
    }
  },
  methods: {
    changeUrl (item) {
      this.$emit('changeUrl', item)
    },
    playMovie (item) {
      this.$emit('playMovie', item)
    },
    reverse () {
      this.pageList = this.pageList.reverse()
    }
  }
}
</script>

<style lang="scss" scoped>
.play-source{
  .online-play{
    margin-top: 10px;
    margin-bottom: 10px;
    .play-url{
      margin-bottom: 15px;
      line-height: 20px;
      display: flex;
      align-items: center;
      .u-item{
        padding: 5px 10px;
        cursor: pointer;
        &:hover{
          color: #00C064;
        }
        .icon{
          color: #00C064;
          font-size: 16px;
          vertical-align: text-bottom;
        }
      }
    }
    .page-box{
      padding: 10px 20px;
      border: 1px solid #dadada;
      background: #f3f3f3;
      position: relative;
      .icon-page{
        width: 15px;
        height: 15px;
        background: #f3f3f3;
        border-top: 1px solid #dadada;
        border-right: 1px solid #dadada;
        box-sizing: border-box;
        position: absolute;
        top: -8px;
        left: 25px;
        transform: rotate(-45deg);
      }
      .pages{
        margin-left: -1%;
        margin-right: -1%;
        padding: 5px 0;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        .page-item{
          width: 23%;
          margin: 5px 1%;
          line-height: 30px;
          background: #fff;
          border: 1px solid #dadada;
          box-sizing: border-box;
          border-radius: 2px;
          text-align: center;
          cursor: pointer;
          &:hover{
            color: #fff;
            background: #00C064;
            border-color: #00C064;
          }
        }
      }
      .sort{
        padding-top: 5px;
        border-top: 1px solid #dadada;
        .s-pos,.s-neg{
          display: inline-block;
          padding: 5px 10px;
          cursor: pointer;
        }
        span+span{
          margin-left: 10px;
        }
      }
    }
  }
}
</style>
